﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Marmat.Forms;

namespace Marmat.Template.WinForm
{
    /// <summary>
    /// 关联控件。
    /// </summary>
    public class AdvRelationControl : Marmat.Forms.DropDownBox
    {
        /// <summary>
        /// 初始化 Marmat.Template.WinForm.AdvRelationControl 类的新实例。
        /// </summary>
        public AdvRelationControl()
        {
            this.ShowDropDownButton = false;
            this.TextEditStyle = TextEditStyles.DisableTextEditor;
        }

        /// <summary>
        /// 设置服务提供者
        /// </summary>
        /// <typeparam name="Entity"></typeparam>
        public AdvRelationControlImplement<Entity> SetProvider<Entity>()
        {
            return new AdvRelationControlImplement<Entity>(this);
        }

        /// <summary>
        /// 获取或设置默认的筛选条件
        /// </summary>
        [DefaultValue(null)]
        [Browsable(false)]
        public string Filter { get; set; }

        /// <summary>
        /// 是否显示下拉按钮。
        /// </summary>
        [DefaultValue(false)]
        public override bool ShowDropDownButton
        {
            get => base.ShowDropDownButton;
            set => base.ShowDropDownButton = value;
        }

        /// <summary>
        /// 获取或设置控件的文本编辑风格。
        /// </summary>
        [DefaultValue(typeof(TextEditStyles), "DisableTextEditor")]
        public new TextEditStyles TextEditStyle
        {
            get => base.TextEditStyle;
            set => base.TextEditStyle = value;
        }
    }
}
